Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bulk transformations functionality #49

Merged
merged 4 commits into from
Aug 9, 2023

Conversation

Virviil
Copy link
Contributor

@Virviil Virviil commented Aug 7, 2023

Bulk encoding transformations added as discussed here: #44 (comment)

Naming and API discussible. Hope I didn't miss something.

@josevalim
Copy link
Contributor

The general direction LGTM!

Copy link
Member

@jonatanklosko jonatanklosko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

lib/tokenizers/tokenizer.ex Outdated Show resolved Hide resolved
Comment on lines +19 to +20
@spec pad(non_neg_integer(), Tokenizers.Encoding.padding_opts()) ::
{:pad, {non_neg_integer(), Tokenizers.Encoding.padding_opts()}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved option types directly to the relevant functions, so we no longer have that type. We can bring it back, but it's also fine to just say keyword() since we point to the user to Encoding.pad/3 anyway :)

Suggested change
@spec pad(non_neg_integer(), Tokenizers.Encoding.padding_opts()) ::
{:pad, {non_neg_integer(), Tokenizers.Encoding.padding_opts()}}
@spec pad(non_neg_integer(), keyword()) :: {:pad, {non_neg_integer(), keyword()}}

Copy link
Contributor Author

@Virviil Virviil Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jonatanklosko I'm not sure that having opts inside function spec and not as a type is good idea (at least here). Using keyword() removes the ElixirLS ability to autosuggest, while having full list of opts in every function is a duplication and can lead to inconsistency, when in the future commits one place will be updated and other - no. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I wasn't aware ElixirLS does that, I don't have strong opinion, but that's a fair argument. So in this case we can bring the type back to share it :)

Copy link
Contributor Author

@Virviil Virviil Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this is how it looks:

image

It take it from spec, so keyword() is less expressive.

I'll take a look how to return types at least for these functions

Copy link
Member

@jonatanklosko jonatanklosko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jonatanklosko jonatanklosko merged commit 0aae295 into elixir-nx:main Aug 9, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants